package cn.weiyang.action;

import cn.weiyang.biz.StreetBiz;
import cn.weiyang.biz.StreetBizImpl;
import cn.weiyang.entity.Street;
import com.google.gson.Gson;

import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2017/7/10.
 */
public class StreetAction extends BaseAction {
    private String did;
    /**
     * 查询所有街道
     * @return
     */
    public String queryStreet() throws IOException {
        StreetBiz sb=new StreetBizImpl();
        if("".equals(did)){
            did=null;
        }
        List<Street> streets=sb.queryStreet(Integer.parseInt(did));
        Gson gson = new Gson();
        //在这里转化成json
        String json =gson.toJson(streets);
        System.out.println(json);
        getResponse().setContentType("application/json;charset=UTF-8");
        getResponse().getWriter().println(json);
        return null;
    }

    public String getDid() {
        return did;
    }

    public void setDid(String did) {
        this.did = did;
    }
}
